package io.first_acquaintance;

import java.io.*;

/**
 * @author haomin
 * @date 2022/06/07 10:44
 **/
public class Main9 {
    public static void main(String[] args) throws IOException {
//        File file = new File("C:\\Users\\86187\\IdeaProjects\\javaEE_learn\\src\\io\\first_acquaintance\\aa.txt");
//
//        try(FileOutputStream outputStream = new FileOutputStream(file);){
//            for (int i = 0; i < 10; i++) {
//                outputStream.write((char)i);
//            }
//        }
        File file = new File("C:\\Users\\86187\\IdeaProjects\\javaEE_learn\\src\\io\\first_acquaintance\\aa.txt");
        try (FileInputStream inputStream = new FileInputStream(file);){
//            int b ;
//            while ((b = inputStream.read()) != -1){
//                System.out.println(b);
//            }

//            byte[] bur = new byte[20];
//            int num = inputStream.read(bur);
//            for (int i = 0; i < num; i++) {
//                System.out.println(bur[i]);
//            }
            byte[] bur = new byte[5];
            int num;
            int count = 0;
            while ((num = inputStream.read(bur)) != -1){
                count++;
                for (int i = 0; i < num; i++) {
                    System.out.println(bur[i]);
                }
            }
            System.out.println("count: "+count);
        }
    }
}